//
//  Button+category.swift
//  JKWeiBo
//
//  Created by 王冲 on 2017/6/4.
//  Copyright © 2017年 希爱欧科技有限公司. All rights reserved.
//

import UIKit

extension UIButton{
    
    class func createButton(tittleName: String,tittleColor:UIColor,target: Any?, action: Selector) -> UIButton{
        
        let rightBtn = UIButton()
        //  rightBtn.setImage(UIImage(named: name), for: UIControlState.normal)
        //  rightBtn.setImage(UIImage(named: name + "_highlighted"), for: UIControlState.highlighted)
        rightBtn.setTitleColor(tittleColor, for: UIControlState.normal)
        //rightBtn.backgroundColor = UIColor.brown
        rightBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        rightBtn.setTitle(tittleName, for: UIControlState.normal)
        // button自适应大小
        rightBtn.sizeToFit()
        rightBtn.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        return rightBtn
    }
    
    class func createButtonImage(imageName: String,target: Any?, action: Selector) -> UIButton{
        
        let rightBtn = UIButton()
        rightBtn.setImage(UIImage(named: imageName), for: UIControlState.normal)
        rightBtn.setImage(UIImage(named: imageName + "_highlighted"), for: UIControlState.selected)
        // button自适应大小
        rightBtn.sizeToFit()
        rightBtn.addTarget(target, action: action, for: UIControlEvents.touchUpInside)
        return rightBtn
    }
    
    class func creatHomeButton(imageName: NSString,tittleName: String)-> UIButton {
        
        let btn = UIButton()
        btn.x = 0
        btn.y = 0
        btn.height = 44
        btn.width = JKscreenW/3.0 as CGFloat
        btn.setTitleColor(UIColor.JKTextGayColor(), for: UIControlState.normal)
        btn.setTitle(tittleName as String, for: UIControlState.normal)
        btn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 10)
        btn.setBackgroundImage(UIImage(named:"timeline_card_bottom_background"), for: UIControlState.normal)
        btn.setImage(UIImage(named:imageName as String), for: UIControlState.normal)
        
        return btn
        
    }
    

    
}
